#ifndef __QF_EVENT_H__
#define __QF_EVENT_H__

typedef int EVerr;

enum {
	EVSuccess = 0,
	EVError = 1,
};

struct qf_event_s {
	int fd;
	long timeout;
	short ev_type;
	void (* callback)(int, short, void *);
	qf_event_s (int fd, short type, void (*cb)(int, short, void *)) :
				fd (fd),
				ev_type (type),
				timeout (0),
				callback (cb) {};
	bool operator< (struct qf_event_s *&rhs)
	{
		return timeout < rhs->timeout;
	}
};

typedef struct qf_event_s qf_event_p;

class qf_event_base {
public:
	enum {
		QF_EV_INIT = 0,
		QF_EV_READ = 1,
		QF_EV_WRITE = 2,
		QF_EV_TIMEOUT = 3,
	};
	qf_event_base ();
	virtual ~qf_event_base ();
	virtual qf_event_p event_new (int, short, void (*)) = 0;
	virtual EVerr event_add (qf_event_p, long) = 0;
	virtual EVerr event_remove (qf_event_p) = 0;
	virtual EVerr event_del (qf_event_p) = 0;
	virtual EVerr event_dispatch () = 0;
};
#endif
